package com.study.gank.mvp.presenter

import com.study.gank.di.component.GankGoodsModule
import com.study.gank.mvp.contract.GankGoodsContract
import com.study.gank.mvp.model.GankModel
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject

class GankGoodsPresenter @Inject constructor(
    private val mModel: GankModel,
    private val mView: GankGoodsContract.View
) : GankGoodsContract.Presenter, BasePresenter() {
    override fun getdata(page: Int, type: String) {
        addDisposable(
            mModel.getData(page, type).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({ res ->
                    if (res.status == 100) {
                        mView.onShowData(res.data)
                    }
                }, { e -> println("error->${e}") })
        )
    }
}